package nc.vo.erm.fysq;

import nc.vo.erm.matterapp.AggMatterAppVO;
import nc.vo.erm.matterapp.MtAppDetail1VO;
import nc.vo.erm.matterapp.MtAppDetailVO;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.IVOMeta;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.pubapp.pattern.model.meta.entity.bill.BillMetaFactory;
import nc.vo.pubapp.pattern.model.meta.entity.bill.IBillMeta;
import nc.web.erm.utils.ERMValueCheck;

public class FYSQBillVO
  extends AbstractBill
{
  private static final long serialVersionUID = 1L;
  
  public FYSQBillVO() {}
  
  public IBillMeta getMetaData()
  {
    return BillMetaFactory.getInstance().getBillMeta(AggFYSQVOMeta.class);
  }
  
  public AggMatterAppVO toAggMatterAppVO()
  {
    MtAppDetailVO[] bxBusItemVOArr = null;
    IVOMeta childvomate = new MtAppDetailVO().getMetaData();
    if (ERMValueCheck.isNotEmpty(getChildren(childvomate))) {
      bxBusItemVOArr = new MtAppDetailVO[getChildren(childvomate).length];
      for (int i = 0; i < getChildren(childvomate).length; i++) {
        bxBusItemVOArr[i] = ((MtAppDetailVO)getChildren(childvomate)[i]);
      }
    }
    
    MtAppDetail1VO[] fjItemVOArr = null;
    IVOMeta vomate = new MtAppDetail1VO().getMetaData();
    if (ERMValueCheck.isNotEmpty(getChildren(vomate))) {
    	fjItemVOArr = new MtAppDetail1VO[getChildren(vomate).length];
      for (int i = 0; i < getChildren(vomate).length; i++) {
    	  fjItemVOArr[i] = ((MtAppDetail1VO)getChildren(vomate)[i]);
      }
    }
    AggMatterAppVO aggMatterAppVO = new AggMatterAppVO();
    aggMatterAppVO.setParentVO((CircularlyAccessibleValueObject)getParent());
    aggMatterAppVO.setChildren(childvomate,bxBusItemVOArr);
    aggMatterAppVO.setChildren(vomate,fjItemVOArr);
    return aggMatterAppVO;
  }
  
  public static FYSQBillVO getFYSQBillVO(AggMatterAppVO bxvo) {
    FYSQBillVO billvo = new FYSQBillVO();
    billvo.setParentVO(bxvo.getParentVO());
    billvo.setChildren(MtAppDetailVO.class, null == bxvo.getChildrenVO() ? new MtAppDetailVO[0] : bxvo.getChildrenVO());
    billvo.setChildren(new MtAppDetail1VO().getMetaData(), bxvo.getChildren(new MtAppDetail1VO().getMetaData()) == null ? new MtAppDetail1VO[0] : bxvo.getChildren(new MtAppDetail1VO().getMetaData()));
    
    return billvo;
  }
}